
class Regex(object):
    # IP
    RE_IP_V4 = r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
    RE_IP_V6 = r"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"
    # e-mail
    RE_EMAIL = r"^[\w-]+(?:\.[\w-]+)*@[\w-]+(?:\.[\w-]+)+$"
    # 域名
    RE_DOMAIN_NAME = r"^[\w-]+(?:\.[\w-]+)+$"
    # 网址
    RE_NET_URL = r"^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])* $"
    # 手机号
    RE_PHONE= r"^(?:13[0-9]|14[5|7]|15[0-3|5-9]|18[0-3|5-9])\d{8}$"
    # 电话号
    RE_TEL_NUM = r"^(\(\d{3,4}-)|\d{3.4}-)?\d{7,8}$ "
    # 国内电话号
    RE_TEL_NUM_CN = r"\d{3}-\d{8}|\d{4}-\d{7}"
    # 身份证(短)
    RE_ID_CARD_15 = r"^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$"
    # 身份证(18)
    RE_ID_CARD_18 = r"^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$"
    # 标准用户名
    RE_USERNAME = r"^[a-zA-Z][a-zA-Z0-9_]{4,15}$"
    # 标准密码
    RE_PASSWORD = r"^[a-zA-Z]\w{5,17}$"
    # 强密码
    RE_DATE = r"^\d{4}-\d{1,2}-\d{1,2}"


if __name__ == "__main__":
    import re

    print(re.findall(Regex.RE_IP_V4, "121.0.0.1"))
    print(re.findall(Regex.RE_IP_V4, "121.0.0.1111"))

    print(re.findall(Regex.RE_EMAIL, "admin@ermao.net"))
    print(re.findall(Regex.RE_EMAIL, "asdasdad@@admin@ermao.net"))

    print(re.findall(Regex.RE_DOMAIN_NAME, "www.w-ermao.net"))

    print(re.findall(Regex.RE_NET_URL, "http://www.w-ermao.net"))

    print(re.findall(Regex.RE_PHONE, "18691556782"))
    